<template>
  <div>
    <el-form :model="classForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item class="name" label="资源库名称" prop="ClassName">
        <el-input v-model="classForm.ClassName"></el-input>
      </el-form-item>
      <el-form-item label="上传学院" prop="College">
        <el-select v-model="classForm.College" placeholder="请选择所属学院">
          <el-option label="计算机学院" value="computed"></el-option>
          <el-option label="彼得堡航空学院" value="bidebao"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="创建时间" required>
        <el-col :span="11">
          <el-form-item prop="time">
            <el-date-picker type="date" placeholder="选择日期" v-model="classForm.time" style="width: 200px;"></el-date-picker>
          </el-form-item>
        </el-col>
      </el-form-item>
<!--      <el-form-item label="班级权限" prop="status">-->
<!--        <el-checkbox-group v-model="classForm.status">-->
<!--          <el-checkbox label="创建班级资料库" name="type"></el-checkbox>-->
<!--          <el-checkbox label="修改学生信息" name="type"></el-checkbox>-->
<!--          <el-checkbox label="修改班级信息" name="type"></el-checkbox>-->
<!--          <el-checkbox label="修改教师信息" name="type"></el-checkbox>-->
<!--        </el-checkbox-group>-->
<!--      </el-form-item>-->
      <el-form-item label="是否公开" prop="tag">
        <el-radio-group v-model="classForm.tag">
          <el-radio label="所有人可见"></el-radio>
          <el-radio label="仅教师可见"></el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="备注" prop="desc">
        <el-input type="textarea"  class="area" v-model="classForm.desc"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data () {
    return {
      classForm: {
        ClassName: "",
        status: [],
        time: "",
        College: "",
        desc: "",
        tag: ""
      },
      rules: {
        ClassName: [
          { required: true, message: "请输入资料库名称", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" }
        ],
        College: [
          { required: true, message: "请选择所属学院", trigger: "change" }
        ],
        time: [
          { type: "data", required: true, message: "请选择创建日期", trigger: "change" }
        ],
        status: [
          { type: "array", required: true, message: "请至少选择一个班级权限", trigger: "change" }
        ],
        tag: [
          { required: true, message: "请选择报到情况", trigger: "change" }
        ]
      }
    }
  },
  methods: {
    submitForm (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert("submit!")
        } else {
          console.log("error submit!!")
          return false
        }
      })
    },
    resetForm (formName) {
      this.$refs[formName].resetFields()
    }
  }
}
</script>

<style scoped>
.name{
  width: 500px;
}
.area{
  width: 800px;
}
</style>
